package com.ize.controller.student;

import com.ize.entity.dto.addStudentYuYueDto;
import com.ize.entity.pojo.Reservation;
import com.ize.result.Result;
import com.ize.service.YuYueService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("StudentYuYue")
@RequestMapping("/student/appointment")
@Slf4j
@Api(tags = "预约相关接口")
@RequiredArgsConstructor
public class YuYueController {

    private final YuYueService yuYueService;

    @PostMapping("/add")
    @ApiOperation("学生预约")
    public Result add(@RequestBody addStudentYuYueDto addStudentYuYueDto) {
        log.info("学生预约{}", addStudentYuYueDto);
        yuYueService.add(addStudentYuYueDto);
        return Result.success();
    }

    @GetMapping("/getYuYue")
    @ApiOperation("获取预约记录")
    public Result<List<Reservation>> getYuYue() {
        log.info("正在获取预约记录...");
        List<Reservation> list = yuYueService.getYu();
        return Result.success(list);
    }

    @PostMapping("/cancel")
    @ApiOperation("取消预约")
    public Result cancel(Integer id) {
        log.info("取消预约id{}:",id);
        yuYueService.delete(id);
        return Result.success();
    }
}
